

using System;
using System.Collections.Generic;
using System.Text;
using EntityLayer;
using System.Data;
using DataAccessLayer;
using InfraStructureLayer;

namespace DataLayer
{
	public class datPhotos
	{
		public datPhotos()
		{
		}
		
		#region  Code Factory Generated Methods
		public void DeletePhotosByPhotoId(entPhotos parEntPhotos, DbConnector parDbConnector)
		{
			DbParamCollection insDbParamCollection = new DbParamCollection();
			insDbParamCollection.Add("@pPhotoId",parEntPhotos.PhotoId);
			parDbConnector.ExecuteNonQuery("DeletePhotosByPhotoId",insDbParamCollection);
		}
		public void InsertPhotos(entPhotos parEntPhotos, DbConnector parDbConnector)
		{
			DbParamCollection insDbParamCollection = new DbParamCollection();
			insDbParamCollection.Add("@pPhotoAlbumId",parEntPhotos.PhotoAlbumId);
			insDbParamCollection.Add("@pPhotoDescription",parEntPhotos.PhotoDescription);
			insDbParamCollection.Add("@pPhotoPath",parEntPhotos.PhotoPath);
            insDbParamCollection.Add("@pDatePictureTaken", parEntPhotos.DatePictureTaken);
			insDbParamCollection.AddOutput("@pPhotoId",DbType.Int32);
			parDbConnector.ExecuteNonQuery("InsertPhotos",insDbParamCollection);
			parEntPhotos.PhotoId = Convert.ToInt32(insDbParamCollection.GetOutPutParameter().Value);
		}
		public void UpdatePhotosByPhotoId(entPhotos parEntPhotos, DbConnector parDbConnector)
		{
			DbParamCollection insDbParamCollection = new DbParamCollection();
			insDbParamCollection.Add("@pPhotoId",parEntPhotos.PhotoId);
			
			insDbParamCollection.Add("@pPhotoAlbumId",parEntPhotos.PhotoAlbumId);
			insDbParamCollection.Add("@pPhotoDescription",parEntPhotos.PhotoDescription);
			insDbParamCollection.Add("@pPhotoPath",parEntPhotos.PhotoPath);
            insDbParamCollection.Add("@pDatePictureTaken", parEntPhotos.DatePictureTaken);
			parDbConnector.ExecuteNonQuery("UpdatePhotosByPhotoId",insDbParamCollection);
		}
		public DataTable SelectPhotos(DbConnector parDbConnector)
		{
			
			return parDbConnector.ExecuteDataTable("SelectPhotos",null);
		}
		public void SelectPhotosByPhotoId(entPhotos parEntPhotos, DbConnector parDbConnector)
		{
			DbParamCollection insDbParamCollection = new DbParamCollection();
			insDbParamCollection.Add("@pPhotoId",parEntPhotos.PhotoId);
			DataTable insDataTable = new DataTable();
			insDataTable = parDbConnector.ExecuteDataTable("SelectPhotosByPhotoId",insDbParamCollection);
			if (insDataTable.Rows.Count>0)
			{
				if (insDataTable.Rows[0]["PhotoId"]!=DBNull.Value)
				{
					parEntPhotos.PhotoId = Convert.ToInt32(insDataTable.Rows[0]["PhotoId"]);
				}
				if (insDataTable.Rows[0]["PhotoAlbumId"]!=DBNull.Value)
				{
					parEntPhotos.PhotoAlbumId = Convert.ToInt32(insDataTable.Rows[0]["PhotoAlbumId"]);
				}
				if (insDataTable.Rows[0]["PhotoDescription"]!=DBNull.Value)
				{
					parEntPhotos.PhotoDescription = insDataTable.Rows[0]["PhotoDescription"].ToString();
				}
				if (insDataTable.Rows[0]["PhotoPath"]!=DBNull.Value)
				{
					parEntPhotos.PhotoPath = insDataTable.Rows[0]["PhotoPath"].ToString();
				}
                if (insDataTable.Rows[0]["DatePictureTaken"] != DBNull.Value)
                {
                    parEntPhotos.DatePictureTaken = Convert.ToDateTime(insDataTable.Rows[0]["DatePictureTaken"]);
                }
			}
		}

		#endregion
        public void DeletePhotosByPhotoAlbumId(entPhotos parEntPhotos, DbConnector parDbConnector)
        {
            DbParamCollection insDbParamCollection = new DbParamCollection();
            insDbParamCollection.Add("@pPhotoAlbumId", parEntPhotos.PhotoAlbumId);
            parDbConnector.ExecuteNonQuery("DeletePhotosByPhotoAlbumId", insDbParamCollection);
        }
        public DataTable SelectPhotosByPhotoAlbumId(entPhotos parEntPhotos, DbConnector parDbConnector)
        {
            DbParamCollection insDbParamCollection = new DbParamCollection();
            insDbParamCollection.Add("@pPhotoAlbumId", parEntPhotos.PhotoAlbumId);
            return parDbConnector.ExecuteDataTable("SelectPhotosByPhotoAlbumId", insDbParamCollection);
        }
        public DataTable SelectPhotosRandom(DbConnector parDbConnector)
        {
            DbParamCollection insDbParamCollection = new DbParamCollection();
            insDbParamCollection.Add("@pLanguageId", CurrentContext.LanguageId);
            return parDbConnector.ExecuteDataTable("SelectPhotosRandom", insDbParamCollection);
        }
        public DataTable SelectPhotosByLanguageId(DbConnector parDbConnector)
        {
            DbParamCollection insDbParamCollection = new DbParamCollection();
            insDbParamCollection.Add("@pLanguageId", CurrentContext.LanguageId);
            return parDbConnector.ExecuteDataTable("SelectPhotosByLanguageId", insDbParamCollection);
        }
        public DataTable SelectPhotosByLanguageIdAndPhotoAlbumId(entPhotos parEntPhotos, DbConnector parDbConnector)
        {
            DbParamCollection insDbParamCollection = new DbParamCollection();
            insDbParamCollection.Add("@pLanguageId", CurrentContext.LanguageId);
            insDbParamCollection.Add("@pPhotoAlbumId", parEntPhotos.PhotoAlbumId);
            return parDbConnector.ExecuteDataTable("SelectPhotosByLanguageIdAndPhotoAlbumId", insDbParamCollection);
        }
        public DataTable SelectPhotosByLanguageIdAndPhotoId(entPhotos parEntPhotos, DbConnector parDbConnector)
        {
            DbParamCollection insDbParamCollection = new DbParamCollection();
            insDbParamCollection.Add("@pLanguageId", CurrentContext.LanguageId);
            insDbParamCollection.Add("@pPhotoId", parEntPhotos.PhotoId);
            return parDbConnector.ExecuteDataTable("SelectPhotosByLanguageIdAndPhotoId", insDbParamCollection);
        }
	}
}